﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using cbmobile.DAC;
using PQT.API;
using System.Data;
using cbmobile.BLC;

namespace cbmobile.MasterUser.BLC_USER
{
    public class BLC_SlideListPK
    {
        private CBMobileEntities da = null;

        public BLC_SlideListPK()
        {
            da = new CBMobileEntities();
        }

        public IList<PhuKien> All_Accessories()
        {
            return da.PhuKiens.ToList();
        }

        public PhuKien Get_Accessories_byID(int Ma_PK)
        {
            IList<PhuKien> list = da.PhuKiens.Where(p => p.Ma_PhuKien == Ma_PK).ToList();
            if (list.Count() == 0)
                return null;
            return list.First();
        }

        //public PhuKien Get_Accessorries_byMASP(int Ma_SP)
        //{
        //    IList<PhuKien> list=da.PhuKiens.Where(p=>p.m)
        //}

        public IList<PhuKien> Rows_PhuKien(int p_page, int p_pagaSize, string p_name)
        {
            int preCount = (p_page - 1) * p_pagaSize;
            IList<PhuKien> list = da.PhuKiens.Where(z => z.Ten_PhuKien.Contains(p_name)).OrderByDescending(z => z.Ten_PhuKien).Skip(preCount).Take(preCount + p_pagaSize).ToList();
            return list;
        }

        public int GetTotalRecord(string p_name)
        {
            return da.PhuKiens.Where(z => z.Ten_PhuKien.Contains(p_name)).Count();
        }



    }
}